package de.gbeine.java.depview.ui.component;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JSeparator;

import com.google.common.eventbus.EventBus;

import de.gbeine.java.depview.event.ChangeLayoutEvent;
import de.gbeine.java.depview.event.OpenFileEvent;
import de.gbeine.java.depview.layout.CircleLayoutStrategy;
import de.gbeine.java.depview.layout.SpringLayoutStrategy;
import de.gbeine.java.depview.ui.MainWindow;

public class LayoutMenu extends JMenu {

    /**
     *
     */
    private static final long serialVersionUID = -4654003806295643916L;

    private EventBus eventBus;

    public LayoutMenu(final EventBus pEventBus) {
        super("Layout");
        this.initialize();
        this.eventBus = pEventBus;
    }

    private void initialize() {
        final JMenuItem mntmSpringLayout = new JMenuItem("Spring Layout");
        mntmSpringLayout.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent e) {
                LayoutMenu.this.eventBus.post(new ChangeLayoutEvent(LayoutMenu.this, new SpringLayoutStrategy() ));
            }
        });
        this.add(mntmSpringLayout);

        final JMenuItem mntmCircleLayout = new JMenuItem("Circle Layout");
        mntmCircleLayout.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent e) {
                LayoutMenu.this.eventBus.post(new ChangeLayoutEvent(LayoutMenu.this, new CircleLayoutStrategy() ));
            }
        });
        this.add(mntmCircleLayout);
    }
}
